package config

import (
	"common/helper"
	"database/sql"
)

type CfgAnnouncement struct {
	Id          string `json:"id" db:"id" cbor:"id"`
	Images      string `json:"images" db:"images" cbor:"images"`
	RedirectUrl string `json:"redirect_url" db:"redirect_url" cbor:"redirect_url"`
	Sort        string `json:"sort" db:"sort" cbor:"sort"`
	Length      string `json:"length" db:"length" cbor:"length"`
	Width       string `json:"width" db:"width" cbor:"width"`
	JumpType    int    `json:"jump_type" db:"jump_type" cbor:"jump_type"` //1内链接，2外链接
	Content     string `json:"content" db:"content" cbor:"content"`
	AnnouTitle  string `json:"annou_title" db:"annou_title" cbor:"annou_title"`
	FuncType    int    `json:"func_type" db:"func_type" cbor:"func_type"`
}

/*
	Nullity       int    `json:"nullity" db:"nullity" cbor:"nullity"`
	FuncType      int    `json:"func_type" db:"func_type" cbor:"func_type"`
	Sort          int    `json:"sort" db:"sort" cbor:"sort"`
	AnnouTitle    string `json:"annou_title" db:"annou_title" cbor:"annou_title"`
	AnnouUrl      string `json:"annou_url" db:"annou_url" cbor:"annou_url"`
	AnnouShareUrl string `json:"annou_share_url" db:"annou_share_url" cbor:"annou_share_url"`
	AnnouPcUrl    string `json:"annou_PC_url" db:"annou_PC_url" cbor:"annou_PC_url"`
*/

var G_cfgAnnouncementList []CfgAnnouncement

func GetCfgAnnouncement() []CfgAnnouncement {
	return G_cfgAnnouncementList
}

func AnnouncementSetRow(rows *sql.Rows) {
	var tVal CfgAnnouncement
	var err error
	err = rows.Scan(&tVal.Id, &tVal.Images, &tVal.RedirectUrl, &tVal.Sort, &tVal.Length, &tVal.Width, &tVal.JumpType, &tVal.Content, &tVal.FuncType, &tVal.AnnouTitle)

	if err != nil {
		helper.InfoLog("AnnouncementSetRow scan err")
		return
	}
	G_cfgAnnouncementList = append(G_cfgAnnouncementList, tVal)
}

func AnnouncementRemove() {
	G_cfgAnnouncementList = []CfgAnnouncement{}
}
